﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Common;

namespace SYH.System.BLL
{
    public class SystemAdmin
    {
        public static readonly SYH.System.DAL.SystemAdmin dal = new DAL.SystemAdmin();

        #region 基本方法
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public static bool Exists(int Id)
        {
            return dal.Exists(Id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(SYH.System.Model.SystemAdmin model)
        {
           
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(SYH.System.Model.SystemAdmin model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public static bool Delete(int Id)
        {
            return dal.Delete(Id);
        }

        /// <summary>
        /// 批量删除数据
        /// </summary>
        public static bool DeleteList(string Idlist)
        {
            return dal.DeleteList(Idlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static SYH.System.Model.SystemAdmin GetModel(int Id)
        {
            return dal.GetModel(Id);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public static DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        #endregion

        #region 管理员列表
        public static DataSet GetList(string strWhere, bool b)
        {
            return dal.GetList(strWhere, b);
        }
        #endregion

        #region 验证登陆
        public static SYH.System.Model.SystemAdmin GetModel(string userName, string passWord)
        {
            return dal.GetModel(userName, passWord);
        }
        #endregion


        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="OldPwd">明文</param>
        /// <param name="NewPwd">明文</param>
        /// <returns>0:旧密码不正确 1:成功 -1:失败</returns>
        public static int UpdatePassword(int UserId, string OldPwd, string NewPwd)
        {
            OldPwd = Common.MD5.Md5En(OldPwd);
            NewPwd = Common.MD5.Md5En(NewPwd);
            return dal.UpdatePassword(UserId, OldPwd, NewPwd);
        }
        #endregion
    }
}
